
@file:Suppress("NOTHING_TO_INLINE")

package com.hzw.core.view

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.CheckResult
import androidx.annotation.LayoutRes
import com.hzw.core.services.layoutInflater

@CheckResult
inline fun <V : View> LayoutInflater.inflate(@LayoutRes layoutResId: Int): V {
    @Suppress("UNCHECKED_CAST") return inflate(layoutResId, null, false) as V
}

@CheckResult
inline fun <V : View> Context.inflate(@LayoutRes layoutResId: Int): V {
    return layoutInflater.inflate(layoutResId)
}

inline fun <V : View> ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean): V {
    @Suppress("UNCHECKED_CAST") return layoutInflater.inflate(layoutRes, this, attachToRoot) as V
}

inline fun ViewGroup.inflateAndAttach(@LayoutRes layoutRes: Int) {
    layoutInflater.inflate(layoutRes, this, true)
}
